Skip to content

PYTHON-XXXX Reject extra fields in Extended JSON timestamps#2961

Open
winklemad wants to merge 1 commit into
mongodb:mainfrom
winklemad:fix-json-timestamp-extra-fields
Open

PYTHON-XXXX Reject extra fields in Extended JSON timestamps#2961
winklemad wants to merge 1 commit into
mongodb:mainfrom
winklemad:fix-json-timestamp-extra-fields

Conversation

@winklemad

Copy link
Copy Markdown

PYTHON-XXXX

Changes in this PR

bson.json_util.loads now rejects $timestamp value documents that contain anything other than the required t and i components. Previously, unexpected fields could be silently discarded while constructing bson.timestamp.Timestamp.

This adds regressions for both additional fields and same-length invalid key sets, and updates the changelog and contributor list.

AI assistance disclosure: I used OpenAI Codex to help investigate the existing behavior, search for duplicates, implement the change, and run validation. I reviewed and understand every changed line and can explain and maintain the contribution.

Test Plan

  • python3 -m unittest test.test_json_util.TestJsonUtil.test_timestamp test.test_json_util.TestJsonUtil.test_timestamp_with_invalid_fields
  • python3 -m unittest test.test_json_util test.test_bson_corpus
  • ruff check bson/json_util.py test/test_json_util.py
  • ruff format --check bson/json_util.py test/test_json_util.py
  • python3 -m compileall -q bson/json_util.py test/test_json_util.py
  • git diff --check

All listed checks passed.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add links.

No follow-up work is currently identified. As an external contributor without an existing JIRA ticket, I retained the template PYTHON-XXXX placeholder for a MongoDB employee to update.

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation?
  • Is all relevant documentation updated?

@winklemad
winklemad requested a review from a team as a code owner July 26, 2026 00:34
@winklemad
winklemad requested a review from blink1073 July 26, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant